// src/services/permission.ts
import {request} from '@umijs/max';

// 获取权限列表
export async function getPermissionList(params: any) {
    return request('/best-live-boot/sys/permission/list', {
        method: 'GET',
        params,
    });
}

// 获取菜单权限列表
export async function getPermissionTree(params: any) {
    return request('/best-live-boot/sys/permission/tree', {
        method: 'GET',
        params,
    });
}

// 获取权限列表
export async function getCurRolePermissionList(params: any) {
    return request('/best-live-boot/sys/permission/cur/tree', {
        method: 'GET',
        params,
    });
}

// 删除单个权限
export async function deletePermission(params: { id: number }) {
    return request('/best-live-boot/sys/permission/delete', {
        method: 'PUT',
        params,
    });
}

// 批量删除权限
export async function deletePermissionBatch(params: { ids: number[] }) {
    return request('/best-live-boot/sys/permission/deleteBatch', {
        method: 'PUT',
        params,
    });
}

// 获取权限信息 (用于编辑/详情)
export async function getPermissionInfo(params: { id: number }) {
    return request(`/best-live-boot/sys/permission/queryById`, {
        method: 'GET',
        params,
    });
}

// 添加权限
export async function addPermission(data: any) {
    return request('/best-live-boot/sys/permission/add', {
        method: 'POST',
        data,
    });
}

// 编辑权限
export async function editPermission(data: any) {
    return request('/best-live-boot/sys/permission/edit', {
        method: 'PUT', // 或 POST，根据后端 API 调整
        data,
    });
}

// 获取权限规则列表 (如果需要)
export async function getPermissionRuleList(params: any) {
    return request('/best-live-boot/sys/permission/rule/list', {
        method: 'GET',
        params,
    });
}


// 获取权限规则列表 (如果需要)
export async function bindRolePermission(data: any) {
    return request('/best-live-boot/sys/permission/bindRolePermission', {
        method: 'POST',
        data,
    });
}

// 获取当前用户的权限
export async function getPermissionsByUser() {
    return request('/best-live-boot/sys/permission/queryByUser', {
        method: 'GET',
    });
}

